Skip to content

Commit

Permalink
fix: cache
Browse files Browse the repository at this point in the history
  • Loading branch information
zenghur committed Aug 20, 2019
1 parent 5541caa commit 0e9b618
Showing 1 changed file with 1 addition and 18 deletions.
19 changes: 1 addition & 18 deletions freesia.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,6 @@ func (f *Freesia) Get(e *entry.Entry) error {
}
b, err := f.store.Get(e.Key).Bytes()
switch err {
case redis.Nil:
j := curlew.NewJob()
j.Arg = e
j.Fn = func(ctx context.Context, arg interface{}) error {
return f.Set(arg.(*entry.Entry))
}
f.dispatcher.SubmitAsync(j)
return err
case nil:
err = e.Decode(b)
if err != nil {
Expand Down Expand Up @@ -165,7 +157,6 @@ func (f *Freesia) batchGet(es ...*entry.Entry) ([]*entry.Entry, error) {
return nil, err
}

msetEntries := make([]*entry.Entry, 0, len(cmders))
for _, cmder := range cmders {
cmd, ok := cmder.(*redis.StringCmd)
if !ok {
Expand All @@ -178,7 +169,7 @@ func (f *Freesia) batchGet(es ...*entry.Entry) ([]*entry.Entry, error) {
b, err := cmd.Bytes()
switch err {
case redis.Nil:
msetEntries = append(msetEntries, e)

case nil:
err = e.Decode(b)
if err != nil {
Expand All @@ -196,14 +187,6 @@ func (f *Freesia) batchGet(es ...*entry.Entry) ([]*entry.Entry, error) {
missEntries = append(missEntries, e)
}
}
if len(msetEntries) > 0 {
j := curlew.NewJob()
j.Arg = msetEntries
j.Fn = func(ctx context.Context, arg interface{}) error {
return f.MSet(arg.([]*entry.Entry)...)
}
f.dispatcher.SubmitAsync(j)
}
return missEntries, nil
}

Expand Down

0 comments on commit 0e9b618

Please sign in to comment.