UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'KN32aNpSXb956Zjmeds196FrWhQl/x/BHDjKq4w2d8Q=' 
WHERE 
  key_id = '3a2faef075c0cc78a0df27643d0c3f6f6d837015533210c558551aa34908c464' 
  AND (
    token = 'KN32aNpSXb956Zjmeds196FrWhQl/x/BHDjKq4w2d8Q=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00032