UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'W6RvTZ186teth4XoI41i8z4z9J18PUCaegsVazKHY6k=' 
WHERE 
  key_id = 'd682904bdc5b45c33ed7ab4cc90a30bf3483eb984516bf34d09e9925041e05ad' 
  AND (
    token = 'W6RvTZ186teth4XoI41i8z4z9J18PUCaegsVazKHY6k=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00062