UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'BN8mG7WMnhvk0S8xVd+K4K/3WNH2NvqCWva57AYxzrc=' 
WHERE 
  key_id = '34527795317298aed38de6336cbfd40022d131ab22e8ec985d13aef67263ea87' 
  AND (
    token = 'BN8mG7WMnhvk0S8xVd+K4K/3WNH2NvqCWva57AYxzrc=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00032