@@ -17,15 +17,13 @@ const DEFAULT_CACHE_PREFIX = "orbit::"
17
17
18
18
// GraphCache is a struct that holds the cache stores for the GraphQL cache
19
19
type GraphCache struct {
20
- prefix string
21
- cacheStore cache.Cache
22
- recordCacheStore cache.Cache
23
- queryCacheStore cache.Cache
20
+ prefix string
21
+ cacheStore cache.Cache
22
+ queryCacheStore cache.Cache
24
23
}
25
24
type GraphCacheOptions struct {
26
25
QueryStore cache.Cache
27
26
ObjectStore cache.Cache
28
- RecordStore cache.Cache
29
27
Prefix string
30
28
}
31
29
@@ -37,17 +35,15 @@ const CacheBackendInMemory CacheBackend = "in_memory"
37
35
func NewGraphCache () * GraphCache {
38
36
return NewGraphCacheWithOptions (& GraphCacheOptions {
39
37
ObjectStore : cache .NewInMemoryCache (),
40
- RecordStore : cache .NewInMemoryCache (),
41
38
QueryStore : cache .NewInMemoryCache (),
42
39
})
43
40
}
44
41
45
42
func NewGraphCacheWithOptions (opts * GraphCacheOptions ) * GraphCache {
46
43
return & GraphCache {
47
- prefix : opts .Prefix ,
48
- cacheStore : opts .ObjectStore ,
49
- recordCacheStore : opts .RecordStore ,
50
- queryCacheStore : opts .QueryStore ,
44
+ prefix : opts .Prefix ,
45
+ cacheStore : opts .ObjectStore ,
46
+ queryCacheStore : opts .QueryStore ,
51
47
}
52
48
}
53
49
@@ -325,22 +321,12 @@ func (gc *GraphCache) CacheObject(field string, object map[string]interface{}, p
325
321
id := object ["id" ].(string )
326
322
cacheKey := typename + ":" + id
327
323
gc .cacheStore .Set (gc .Key (cacheKey ), object )
328
-
329
- for key , value := range object {
330
- gc .recordCacheStore .Set (gc .Key (cacheKey + ":" + key ), value )
331
- }
332
-
333
324
return gc .Key (cacheKey )
334
325
} else if utils .StringArrayContainsString (objectKeys , "__typename" ) && ! utils .StringArrayContainsString (objectKeys , "id" ) && parent != nil && utils .StringArrayContainsString (parentKeys , "id" ) && utils .StringArrayContainsString (parentKeys , "__typename" ) {
335
326
typename := parent ["__typename" ].(string )
336
327
parentID := parent ["id" ].(string )
337
328
cacheKey := typename + ":" + parentID + ":" + field
338
329
gc .cacheStore .Set (gc .Key (cacheKey ), object )
339
-
340
- for key , value := range object {
341
- gc .recordCacheStore .Set (gc .Key (cacheKey + ":" + key ), value )
342
- }
343
-
344
330
return gc .Key (cacheKey )
345
331
}
346
332
@@ -571,22 +557,12 @@ func (gc *GraphCache) InvalidateCacheObject(field string, object map[string]inte
571
557
id := object ["id" ].(string )
572
558
cacheKey := typename + ":" + id
573
559
gc .cacheStore .DeleteByPrefix (gc .Key (cacheKey ))
574
-
575
- for key := range object {
576
- gc .recordCacheStore .Del (gc .Key (cacheKey + ":" + key ))
577
- }
578
-
579
560
return gc .Key (cacheKey )
580
561
} else if utils .StringArrayContainsString (objectKeys , "__typename" ) && ! utils .StringArrayContainsString (objectKeys , "id" ) && parent != nil && utils .StringArrayContainsString (parentKeys , "id" ) && utils .StringArrayContainsString (parentKeys , "__typename" ) {
581
562
typename := parent ["__typename" ].(string )
582
563
parentID := parent ["id" ].(string )
583
564
cacheKey := typename + ":" + parentID + ":" + field
584
565
gc .cacheStore .DeleteByPrefix (gc .Key (cacheKey ))
585
-
586
- for key := range object {
587
- gc .recordCacheStore .Del (gc .Key (cacheKey + ":" + key ))
588
- }
589
-
590
566
return gc .Key (cacheKey )
591
567
}
592
568
@@ -595,31 +571,26 @@ func (gc *GraphCache) InvalidateCacheObject(field string, object map[string]inte
595
571
596
572
func (gc * GraphCache ) Debug () {
597
573
gc .cacheStore .Debug ("cacheStore" )
598
- gc .recordCacheStore .Debug ("recordCacheStore" )
599
574
gc .queryCacheStore .Debug ("queryCacheStore" )
600
575
}
601
576
602
577
func (gc * GraphCache ) Look () map [string ]interface {} {
603
578
output := make (map [string ]interface {})
604
579
cacheMap , _ := gc .cacheStore .Map ()
605
- recordCacheMap , _ := gc .recordCacheStore .Map ()
606
580
queryCacheMap , _ := gc .queryCacheStore .Map ()
607
581
608
582
output ["cacheStore" ] = cacheMap
609
- output ["recordCacheStore" ] = recordCacheMap
610
583
output ["queryCacheStore" ] = queryCacheMap
611
584
612
585
return output
613
586
}
614
587
615
588
func (gc * GraphCache ) Flush () {
616
589
gc .cacheStore .Flush ()
617
- gc .recordCacheStore .Flush ()
618
590
gc .queryCacheStore .Flush ()
619
591
}
620
592
621
593
func (gc * GraphCache ) FlushByType (typeName string , id string ) {
622
594
gc .cacheStore .DeleteByPrefix (gc .Key (typeName + ":" + id ))
623
- gc .recordCacheStore .DeleteByPrefix (gc .Key (typeName + ":" + id ))
624
595
gc .queryCacheStore .DeleteByPrefix (gc .Key (typeName + ":" + id ))
625
596
}
0 commit comments