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

Query time 0.00034