comparison pkg/octree/cache.go @ 4214:49564382ffff

Added a import queue job to recalculate the contour lines of the sounding results if the heights have changed.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Fri, 16 Aug 2019 13:15:34 +0200
parents 86c7a023400e
children 4bbfe3dd2ab5
comparison
equal deleted inserted replaced
4197:5d7ce7f926eb 4214:49564382ffff
45 maxCacheAge = 5 * time.Minute 45 maxCacheAge = 5 * time.Minute
46 maxCacheEntries = 4 46 maxCacheEntries = 4
47 ) 47 )
48 48
49 const ( 49 const (
50 directFetchOctreeSQL = `
51 SELECT octree_index FROM waterway.sounding_results
52 WHERE id = $1
53 `
50 fetchOctreeSQL = ` 54 fetchOctreeSQL = `
51 SELECT octree_checksum, octree_index 55 SELECT octree_checksum, octree_index
52 FROM waterway.sounding_results 56 FROM waterway.sounding_results
53 WHERE bottleneck_id = $1 AND date_info = $2::date 57 WHERE bottleneck_id = $1 AND date_info = $2::date
54 AND octree_checksum IS NOT NULL AND octree_index IS NOT NULL 58 AND octree_checksum IS NOT NULL AND octree_index IS NOT NULL
95 ctx context.Context, 99 ctx context.Context,
96 conn *sql.Conn, 100 conn *sql.Conn,
97 bottleneck string, date time.Time, 101 bottleneck string, date time.Time,
98 ) (*Tree, error) { 102 ) (*Tree, error) {
99 return cache.get(ctx, conn, bottleneck, date) 103 return cache.get(ctx, conn, bottleneck, date)
104 }
105
106 // FetchOctreeDirectly loads an octree directly from the database.
107 func FetchOctreeDirectly(
108 ctx context.Context,
109 tx *sql.Tx,
110 id int64,
111 ) (*Tree, error) {
112 var data []byte
113 err := tx.QueryRowContext(ctx, directFetchOctreeSQL, id).Scan(&data)
114 if err != nil {
115 return nil, err
116 }
117 return Deserialize(data)
100 } 118 }
101 119
102 func (c *Cache) get( 120 func (c *Cache) get(
103 ctx context.Context, 121 ctx context.Context,
104 conn *sql.Conn, 122 conn *sql.Conn,