UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'QUY4GmwQKgRHTBsZCWrgJCP9rAWn1Gk5Kur40+zAdR8=' 
WHERE 
  key_id = '8e7ec86030043c1915520c925edbe080b86d4d234d90c6d9b8183a12e9a3d2a5' 
  AND (
    token = 'QUY4GmwQKgRHTBsZCWrgJCP9rAWn1Gk5Kur40+zAdR8=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00041