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